package com.qumitech.visualnovel.controller.rest;

import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.qumitech.visualnovel.pubdef.dto.app.ThirdBindCfgAdminDTO;
import com.qumitech.visualnovel.pubdef.dto.app.ThirdBindCfgAdminQueryDTO;
import com.qumitech.visualnovel.pubdef.dto.app.ThirdBindCfgDetailAdminDTO;
import com.qumitech.visualnovel.pubdef.dto.app.ThirdBindCfgDetailAdminQueryDTO;
import com.qumitech.visualnovel.service.app.AppThirdBindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @Author :  ZhChNing
 * @Descriptiom :
 * @Date Created in 2019/11/19 14:25
 */

@RestController
@RequestMapping(value = "/api/thirdbind")
public class ThirdBindController {

    @Autowired
    private AppThirdBindService thirdBindService;


    @GetMapping("/detail/list")
    public BaseRsp getThirdBindCfgDetailAdminQueryDTOList(ThirdBindCfgDetailAdminQueryDTO queryDTO) {
        return new BaseRsp(ResultEnum.SUCCESS, thirdBindService.listThirdBindCfgDetailDTO(queryDTO));
    }

    @GetMapping("/detail/base/list")
    public BaseRsp getThirdBindCfgDetailBaseAdminQueryDTOList(ThirdBindCfgDetailAdminQueryDTO queryDTO) {
        return new BaseRsp(ResultEnum.SUCCESS, thirdBindService.listThirdBindCfgDetailBaseDTO(queryDTO));
    }


    @PostMapping("/detail")
    public BaseRsp addThirdBindCfgDetail(@RequestBody ThirdBindCfgDetailAdminDTO dto) {
        thirdBindService.addThirdBindCfgDetailAdminDTO(dto);
        return new BaseRsp(ResultEnum.SUCCESS);
    }

    @PostMapping("/detail/{cfg_id}")
    public BaseRsp updateThirdBindCfgDetail(@PathVariable("cfg_id") String cfgId , @RequestBody ThirdBindCfgDetailAdminDTO dto) {
        dto.setCfgId(cfgId);
        thirdBindService.updateThirdBindCfgDetailAdminDTO(dto);
        return new BaseRsp(ResultEnum.SUCCESS);
    }


    @GetMapping("/cfg/list")
    public BaseRsp getThirdBindCfgList(ThirdBindCfgAdminQueryDTO queryDTO) {
        return new BaseRsp(ResultEnum.SUCCESS,  thirdBindService.listThirdBindCfgDTO(queryDTO));
    }

    @PostMapping("/cfg")
    public BaseRsp addThirdBindCfg(@RequestBody ThirdBindCfgAdminDTO dto) {
        thirdBindService.addThirdBindCfgAdminDTO(dto);
        return new BaseRsp(ResultEnum.SUCCESS);
    }

    @PostMapping("/cfg/{bind_id}")
    public BaseRsp updateThirdBindCfg(@PathVariable("bind_id") String bindId , @RequestBody ThirdBindCfgAdminDTO dto) {
        dto.setBindId(bindId);
        thirdBindService.updateThirdBindCfgAdminDTO(dto);
        return new BaseRsp(ResultEnum.SUCCESS);
    }


}
